package cn.net.xyan.easy.gwt.client.model;

import org.gwtbootstrap3.client.ui.constants.IconType;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by zarra on 16/2/17.
 */
public class MenuItemModel {
    String title;
    String icon;
    List<MenuItemModel> items = new LinkedList<MenuItemModel>();

    public MenuItemModel(){

    }

    public MenuItemModel(String title){
        setTitle(title);
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<MenuItemModel> getItems() {
        return items;
    }

    public void setItems(List<MenuItemModel> items) {
        this.items = items;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public IconType icon(){
        if (getIcon() == null || getIcon().length() ==0){

            if (getItems() == null || getItems().size() ==0){
                return IconType.DOT_CIRCLE_O;
            }else{
                return IconType.COGS;
            }

        }else {
            return IconType.fromStyleName(getIcon());
        }
    }

    public boolean isNode(){
        return getItems() == null || getItems().size()==0;
    }
}
